package cn.com.elite;

import java.util.List;

import javax.sql.DataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

public class MailBean {
	private static final Log log=LogFactory.getLog(MailBean.class);
    private DataSource dataSource;
    private DataSourceTransactionManager tran;
	public DataSource getDataSource() {
		return dataSource;
	}
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	public DataSourceTransactionManager getTran() {
		return tran;
	}
	public void setTran(DataSourceTransactionManager tran) {
		this.tran = tran;
	}
	public int update(String sql){
        JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource);
        int resultList=jdbcTemplate.update(sql);
        return resultList;
	}
    public List chaxun(String sql) throws Exception {
        JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource);
        List resultList=jdbcTemplate.queryForList(sql);
        return resultList;
  }
    public String chaxun1(String sql) throws Exception {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        String resultList=(String)jdbcTemplate.queryForObject(sql,java.lang.String.class);
        return resultList;
  }

}
